<?php
include_once "../header1.php";
?>
<script type="text/javascript">
function DeleteVarification()
{
<?php
include_once ("$basedir"."/Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("$basedir"."/index.php");
}
   
   else
   {
   ?>
var School_Id=document.forms["DelExa"]["School_Id"].value;
var Exam_Name=document.forms["DelExa"]["Exam_Name"].value;
var Year=document.forms["DelExa"]["Year"].value;
if (School_Id=="Select One"||Exam_Name=="Select One"||Year=="Select One")
  {
  alert("Please select the Exam name,School Id and Year to delete!");
  return false;
  }
  
if (School_Id!="Select One"&&Exam_Name!="Select One"&&Year!="Select One")
{
var r=confirm("Are you sure to delete this?");
if (r==true)
  {
  return true;
 
 }

if(r==false)
  {
  alert("You pressed cancel!");
 return false;
  }
}
}
</script>
</head>
<body>
  <?php

include_once "../header2.php";


?>
<?php
include_once "topmenu.php";
?>
<div class="left">
  
<div class="articles">
<form  name="DelExa" action="#" method="POST" onSubmit="return DeleteVarification()">
<?php
if(isset($_POST['Delete']))
{
require_once 'DEL.php';
}
?>
  <table width="354" border="0">
    <tr>
      <th height="29" colspan="2"  scope="row">
      <?php
      if(isset($_POST['Delete']))
{
	if(isset($_SESSION['errorin']))
	{
		echo ($_SESSION['errorin']);
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{
		echo ($_SESSION['error']);
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
	if(isset($_SESSION['errornot']))
	{
		echo $_SESSION['errornot'];
		unset($_SESSION['errornot']);
	}
	if(isset($_SESSION['errornot2']))
	{
		echo $_SESSION['errornot2'];
		unset($_SESSION['errornot2']);
	}
}   
?>
</th>
      </tr>
    <tr>
      <th width="200" height="29"  scope="row">School Id:</th>
      <td width="144"><select name="School_Id">
        <?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	  $exa=mysql_query("SELECT DISTINCT(School_Id) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
	 $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <th height="30" scope="row">Exam Name:</th>
      <td><select name="Exam_Name">
     <?php
	  
	  if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$Exam_Name.'">'.$Exam_Name.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	  $exa=mysql_query("SELECT DISTINCT(Exam_Name) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
	 $Exa_Name=$row['Exam_Name'];

	  echo '<option value="'.$Exa_Name.'">'.$Exa_Name.'</option>';
  }
  }
	  ?>
      </select></td>
    </tr>
    <tr>
      <th height="23" scope="row">Year:</th>
      <td><select name="Year">
      <?php
	 if(isset($_POST['Delete']))
	  {
	 echo '<option value="'.$Year.'">'.$Year.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  
	  ?>
        <?php
	 $exa=mysql_query("SELECT DISTINCT(Year) FROM exam");
	  
  while($row=mysql_fetch_array($exa))
  {
  $Yea=$row['Year'];

	  echo '<option value="'.$Yea.'">'.$Yea.'</option>';
  }
  }
	 ?>
      </select></td>
    </tr>
  </table>

  <br/>
      <a href="DelExam.php">Reset</a>|
    <input name="Delete" align="middle" type="submit" value="Delete" onclick="deletevari()" />
 <br/>
   </form>
  <?php
   	   if(isset($_POST['Delete']))
{
	  
	   $School_Id=$_POST['School_Id'];
	   $Exam_Name=$_POST['Exam_Name'];
	   $Year=$_POST['Year'];
if($_SESSION['Access_Type']=="Administrator")
   {
   if(mysql_num_rows($result)!=0)
   {
   echo '<table width="458" border="0">';
	while($row=mysql_fetch_array($result))
  { 
  $s_name=$row['School_Id'];
$Exam=$row['Exam_Name'];
$Ye=$row['Year'];
$No_Of_Sat=$row['No_Of_Sat_Students'];
$No_Of_Passed=$row['No_Of_Passed_Students'];
   
    ?>
    <?php
       echo '<tr>';
        echo '<th width="200" height="44" scope="row">';
		echo "School Id:";
		echo '</th>';
        echo '<td width="144">';
		echo $s_name;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Exam Name:";
		echo '</th>';
        echo '<td>';
		echo $Exam;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Year:";
		echo '</th>';
        echo '<td>';
		echo $Ye;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number Of Sat_Students :";
		echo '</th>';
       echo '<td>';
	   echo $No_Of_Sat;
	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Number Of Passed_Students:"; 
		echo '</th>';
        echo '<td>';
		echo $No_Of_Passed;
            
        echo '</td>';
      echo '</tr>';
       
   }
    echo '</table>';
	}
	}	
	}
    ?>
</div>
</div>

<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
<?php
include_once "../footer.php";
?>
<?php
	  }
  
?>
</body>
</html>